<?php
/**
* Hellos Model for Hello World Component
*
* @package Joomla.Tutorials
* @subpackage Components
* @link http://dev.joomla.org/component/option,com_jdwiki/
Itemid,31/id,tutorials:components/
* @license GNU/GPL
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
jimport( 'joomla.application.component.model' );
/**
* Hello Model
*
* @package Joomla.Tutorials
* @subpackage Components
*/
class HellosModelHellos extends JModel
{
	/**
	* Hellos data array
	*
	* @var array
	*/
	var $_data;
	/**
	* Returns the query
	* @return string The query to be used to retrieve the rows from
	the database
	*/
	function _buildQuery()
	{
		$query = ' SELECT * '
		. ' FROM #__hello '
		;
		return $query;
	}
	
	/**
	* Constructor that retrieves the ID from the request
	*
	* @access public
	* @return void
	*/
	function __construct()
	{
	parent::__construct();
	$array = JRequest::getVar('cid', 0, '', 'array');
	$this->setId((int)$array[0]);
	}

	/**
	* Method to set the hello identifier
	*
	* @access public
	* @param int Hello identifier
	* @return void
	*/
	function setId($id)
	{
	// Set id and wipe data
	$this->_id = $id;
	$this->_data = null;
	}
	
		/**
	* Method to get a hello
	* @return object with data
	*/
	function &getData()
	{
		// Load the data
		if (empty( $this->_data )) {
			//$query = ' SELECT * FROM #__hello'.
			//' WHERE id = '.$this->_id;
			$query = ' SELECT * FROM #__hello ';
			echo ("DUONG VAN TUYEN");
			$this->_db->setQuery( $query );
			$this->_data = $this->_db->loadObject();
		}
		if (!$this->_data) {
			$this->_data = new stdClass();
			$this->_data->id = 0;
			$this->_data->greeting = null;
		}
		return $this->_data;
	}

/**
* Retrieves the hello data
* @return array Array of objects containing the data from the
database
*/
/*function getData()
{
	// Lets load the data if it doesn't already exist
	if (empty( $this->_data ))
	{
	$query = $this->_buildQuery();
	$this->_data = $this->_getList( $query );
	}
	return $this->_data;
}*/
}